﻿using System;
using System.Diagnostics;
using System.Text;
using System.Windows.Controls;
using System.Windows.Data;

namespace Flare.Pages.Hards
{
    public partial class Move : UserControl, ITypicalPage
    {
        public string name
        {
            get { return "Перемещение"; }
        }

        int _eq_id;
        int id_room_old;

        public Move(int eq_id)
        {
            _eq_id = eq_id;
            InitializeComponent();
            var detail = new DB.equipments().Details(eq_id);
            id_room_old = detail.id_room;
        }

        private void ButtonSave_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            try
            {
                new Flare.DB.equipments().Move(_eq_id, id_room_old, (int?)Room.SelectedValue, description.Text);
                ButtonSave.ShowResult();
            }
            catch (Exception ex)
            {
                glob.kernel.ShowNotice(ex.Message);
            }
        }

        private void Department_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ((ObjectDataProvider)this.Resources["general_roomsDataSet"]).MethodParameters[0] = (int?)Department.SelectedValue;
        }

    }
}
